﻿@using Century.Web.Security.Authorizations;
@using Century.Web.Security;
@model Century.Model.CMS.SitePage
@{
    Layout = null;
    var options = new AjaxOptions()
    {
        Url = Url.Action("Settings", "PageManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccess",
        OnFailure = "OnFailure",
        OnComplete = "OnComplete"
    };  
}
@Html.Partial("_MessageBox")
@section scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#PostIT').click(function () {
                $(this).parents('form').submit();
                return false;
            });
        });

        function OnSuccess(data) {
            ReloadTree();
            OpenPopup('Message', 'Site page data successfully saved.', false);
        }

        function OnFailure(data) {
            OpenPopup('Message', 'An error occured during save operation. <br/>Please try again or contact with administrator.', true);
        }

        function OnComplete(data) {
            var iframe = $('#ifrmDesign');
            iframe.attr('src', iframe.attr('src'));
        }
    </script>
}
@{Html.EnableClientValidation();}

@using (Ajax.BeginForm(options))
{
    @Html.ValidationSummary(true);
    @Html.HiddenFor(model => model.ParentId)
    @Html.HiddenFor(model => model.Description)
    @Html.HiddenFor(model => model.Keywords)
    <div style="text-align: left;">
        <div>
            <table border="0" cellspacing="0" cellpadding="0" class="login-tbl">
                <tr>
                    <td colspan="2">
                        <h2>Edit "@(string.IsNullOrEmpty(Model.Title) ? Model.LocalName : Model.Title)" Settings
                            @Html.HiddenFor(model => model.Id)
                            @Html.HiddenFor(model => model.SiteId)
                            @Html.HiddenFor(model => model.Roles)
                        </h2>
                        <br />
                        <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/warning.png")" alt="Warning" />
                        Your changes will be appear on <b>Live</b>. There is no draft or etc. version for these properties
                    </td>
                </tr>
                @*                @if (CenturyAuthorization.Authorize(HttpContext.Current.User.Identity.Name, new ActionModule { Name = "Administration", DisplayName = "Administration" }))
                {
                *@<tr>
                    <td class="lbl">
                        <b>Page Layout</b>
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.PageLayoutId, new SelectList((List<Century.Model.CMS.PageLayout>)ViewData["Layouts"], "Id", "Name"), new { @class = "big" })
                        @Html.ValidationMessageFor(model => model.PageLayoutId)
                    </td>
                </tr>
                @*                }
                else
                {
                <tr>
                    <td class="lbl">
                        <b>Page Layout</b>
                    </td>
                    <td>
                        @Html.HiddenFor(model => model.PageLayoutId)
                        @(Model.PageLayout != null ? Model.PageLayout.Name : string.Empty)
                    </td>
                </tr>
                }*@
                <tr>
                    <td class="lbl">
                        <b>* @Html.LabelFor(model => model.Name)</b>
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.Name, new { @readonly = "readonly", @class = "big inpt_readonly" })
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>* Local Name</b>
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.LocalName, new { @class = "big" })
                        @Html.ValidationMessageFor(model => model.LocalName)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>* @Html.LabelFor(model => model.Title)</b>
                    </td>
                    <td align="left">
                        @Html.TextBoxFor(model => model.Title, new { @class = "big" })
                        @Html.ValidationMessageFor(model => model.Title)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>@Html.LabelFor(model => model.Url)</b>
                    </td>
                    <td align="left">
                        @Html.TextBoxFor(model => model.Url, new { @class = "big" })
                        @Html.ValidationMessageFor(model => model.Url)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Menu Order</b>
                    </td>
                    <td>
                        @(Html.Telerik().NumericTextBox()
                            .Name("NodeOrder")
                            .Spinners(true)
                            .MinValue(0)
                            .MaxValue(100)
                            .EmptyMessage("Enter an order")
                            .DecimalDigits(0)
                            .InputHtmlAttributes(new { @class = "small" })
                        )
                        &nbsp;(min : 0 - max : 100)
                        @Html.ValidationMessageFor(model => model.NodeOrder)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Menu Description</b>
                    </td>
                    <td align="left">
                        @Html.TextAreaFor(model => model.MenuDescription, new { @class = "big high" })
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Banner Image Path</b>
                    </td>
                    <td align="left">
                        @Html.TextBoxFor(model => model.ImagePath, new { @class = "big" })
                        @*@Html.FileExplorerFor("~/Content/themes/default/img/banner/page_header", "ImagePath")*@
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Menu Image Path</b>
                    </td>
                    <td align="left">
                        @Html.TextBoxFor(model => model.MenuImagePath, new { @class = "big" })
                        @*@Html.FileExplorerFor("~/Content/themes/default/img/menu", "MenuImagePath")*@
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Is Home Page</b>
                    </td>
                    <td align="left">
                        @Html.CheckBoxFor(model => model.IsHomePage)
                        @*  @if (CenturyAuthorization.Authorize(HttpContext.Current.User.Identity.Name, new ActionModule { Name = "Administration", DisplayName = "Administration" }))
                        {
                            
                            
                            @Html.CheckBoxFor(model => model.IsHomePage)
                        }
                        else
                        {                            
                            @Html.CheckBoxFor(model => model.IsHomePage, new { disabled = "true" }) <text>{ * only admin(s) can edit this value }</text>
                        }*@
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Show In Menu</b>
                    </td>
                    <td align="left">
                        @Html.CheckBoxFor(model => model.ShowInMenu)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Show In Right Menu</b>
                    </td>
                    <td align="left">
                        @Html.CheckBoxFor(model => model.ShowInRightMenu)
                    </td>
                </tr>
                <tr>
                    <td class="lbl">
                        <b>Is Published</b>
                    </td>
                    <td align="left">
                        @Html.CheckBoxFor(model => model.IsPublished)
                    </td>
                </tr>
                <tr>
                    <td class="lst" colspan="2">
                        <input type="submit" class="btn_green btn" id="PostIT" value="Save" />
                    </td>
                </tr>
                <tr>
                    <td class="lst" colspan="2">
                        <span id="processResult"></span>
                    </td>
                </tr>
            </table>
        </div>
    </div>
}